package vikaa.framework;

import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.view.WindowManager;

public class AppContext extends Application{
	public static final int NETTYPE_WIFI = 0x01;
	public static final int NETTYPE_CMWAP = 0x02;
	public static final int NETTYPE_CMNET = 0x03;
	
	public static final int TEXTANDIMAGE_CREDITS = 5;
	
	public static final int PAGE_SIZE = 20;//default page_siae
	private static final int CACHE_TIME = 60*60000;//缓存失效时间
	private static final int FILE_CACHE_TIME  = 24 * 60 * 6000;//文件缓存是失效时间
	
	
		
	/**
	 * @return
	 */
	public PackageInfo getAppPackageInfo() {
		PackageInfo pi = null;
		try{
			pi = getPackageManager().getPackageInfo(getPackageName(), 0);
		}catch (Exception e) {
			e.printStackTrace();
		}
		if (pi == null) pi = new PackageInfo();
		return pi;
	}
	
	/**
	 * 判断当前版本是否兼容目标版本的方法
	 * @param VersionCode
	 * @return
	 */
	public static boolean isMethodsCompat(int VersionCode) {
		int currentVersion = android.os.Build.VERSION.SDK_INT;
		return currentVersion >= VersionCode;
	}
	 
	
	public  int getDisplayWidth(Context context){
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		return wm.getDefaultDisplay().getWidth();
	}
	
	public  int getDisplayHeighth(Context context){
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		return wm.getDefaultDisplay().getHeight();
	}
}
